home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 1 / Gold Medal Software Volume 1 (Gold Medal) (1994).iso / autocad / 3dfurn.arj / 3DFURN.LSP next >
Text File  |  1993-10-21  |  15KB  |  350 lines

  1. ;;;
  2. ;;;  3d furniture construction.                                        ;
  3. ;;;  Student - Mark Williamson  9-23-92                                ;
  4. ;;;  Instructor - Tim Urbaniak / Drafting dept.  76264,2273            ;
  5. ;;;  Creates basic 3d cabinets, tables, and two types of chairs        ;
  6. ;;;  based on user supplied input. Program allows for the creation     ;
  7. ;;;  of multiple objects.                                              ;
  8. ;;;                                                                    ;
  9. ;;;  Another Billings Vocational Technical Center lab project...       ;
  10. ;;;      Your tax dollars at work...support education in your area.    ;
  11. ;;;            Public Domain                                           ;
  12. ;;;
  13. ;;;This part of the program will draw a 3d chair without arms
  14. ;;;based on the user supplied input.
  15. (defun c:chair ()                    ;get input for variables
  16.   (textscr) 
  17.   (setq sw (getdist "\nWidth of the seat (on the X): "))
  18.   (setq sl (getdist "\nLength of the seat (on the Y): "))
  19.   (setq sh (getdist "\nThickness of the seat (on the Z): "))
  20.   (setq bl (getdist "\nThickness of the back (on the Y): "))
  21.   (setq bh (getdist "\nHeight of the back (on the Z): "))
  22.   (setq lw (getdist "\nWidth of the leg (on the X): "))
  23.   (setq ll (getdist "\nLength of the leg (on the Y): "))
  24.   (setq lh (getdist "\nHeight of the leg (on the Z): "))
  25.   (setq nc (getint "\nNumber of chairs to build ?: "))
  26.   (graphscr) 
  27.   (setvar "blipmode" 0)
  28.   (setvar "cmdecho" 0)               ;set points for base of first leg
  29.   (setq tp (getvar "thickness"))     ;set up for multiple chairs
  30.   (repeat nc 
  31.     (setq sp (getpoint "\nLower left point for construction: ")) ;create the-
  32.                                      ; chair legs
  33.     (setq l1 sp)
  34.     (repeat 2 
  35.       (setq l2 (polar l1 (dtr 0.0) ll))
  36.       (setq l3 (polar l2 (dtr 90) lw))
  37.       (setq l4 (polar l3 (dtr 180) ll))
  38.       (setvar "thickness" lh)
  39.       (command "line" l1 l2 l3 l4 "c") 
  40.       (setvar "thickness" tp)
  41.       (command "3dface" l1 l2 l3 l4 "") 
  42.       (setq l1 (polar l1 (dtr 0.0) (- sl ll)))
  43.     ) 
  44.     (setq l1 sp)
  45.     (setq l1 (polar l1 (dtr 90) (- sw lw)))
  46.     (repeat 2 
  47.       (setq l2 (polar l1 (dtr 0.0) ll))
  48.       (setq l3 (polar l2 (dtr 90) lw))
  49.       (setq l4 (polar l3 (dtr 180) ll))
  50.       (setvar "thickness" lh)
  51.       (command "line" l1 l2 l3 l4 "c") 
  52.       (setvar "thickness" tp)
  53.       (command "3dface" l1 l2 l3 l4 "") 
  54.       (setq l1 (polar l1 (dtr 0.0) (- sl ll)))
  55.     )                                ;set points for top of first leg
  56.     (setq l1 sp)
  57.     (setq l5 (list (car l1) (cadr l1) (+ (caddr l1) lh)))
  58.     (setq l6 (list (car l2) (cadr l2) (+ (caddr l2) lh)))
  59.     (setq l7 (list (car l3) (cadr l3) (+ (caddr l3) lh)))
  60.     (setq l8 (list (car l4) (cadr l4) (+ (caddr l4) lh))) ;set points for seat
  61.     (setq s1 l5)
  62.     (setq s2 (polar s1 (dtr 0.0) sl))
  63.     (setq s3 (polar s2 (dtr 90) sw))
  64.     (setq s4 (polar s3 (dtr 180) sl)) ;set points for top of seat
  65.     (setq s5 (list (car s1) (cadr s1) (+ (caddr s1) sh)))
  66.     (setq s6 (list (car s2) (cadr s2) (+ (caddr s2) sh)))
  67.     (setq s7 (list (car s3) (cadr s3) (+ (caddr s3) sh)))
  68.     (setq s8 (list (car s4) (cadr s4) (+ (caddr s4) sh))) ;set points for back
  69.     (setq b2 s6)
  70.     (setq b1 (polar b2 (dtr 180) bl))
  71.     (setq b4 (polar b1 (dtr 90) sw))
  72.     (setq b3 s7)                     ;set points for the top of the back
  73.     (setq b5 (list (car b1) (cadr b1) (+ (caddr b1) bh)))
  74.     (setq b6 (list (car b2) (cadr b2) (+ (caddr b2) bh)))
  75.     (setq b7 (list (car b3) (cadr b3) (+ (caddr b3) bh)))
  76.     (setq b8 (list (car b4) (cadr b4) (+ (caddr b4) bh))) ;create the chair bas-
  77.                                      ;e
  78.     (setvar "thickness" sh)
  79.     (command "line" s1 s2 s3 s4 "c") 
  80.     (setvar "thickness" tp)
  81.     (command "3dface" s1 s2 s3 s4 "") 
  82.     (command "3dface" s5 b1 b4 s8 "") ;create the chair back
  83.     (setvar "thickness" bh)
  84.     (command "line" b1 b2 b3 b4 "c") 
  85.     (setvar "thickness" tp)
  86.     (command "3dface" b5 b6 b7 b8 "")
  87.   )
  88. ;;;
  89. ;;;This part of the program will draw a 3d table
  90. ;;;based on user specified input.
  91. (defun c:table ()                    ;get input for variables
  92.   (textscr) 
  93.   (setq tw (getdist "\nWidth of the table (on the X): "))
  94.   (setq tl (getdist "\nLength of the table (on the Y): "))
  95.   (setq th (getdist "\nThickness of the table (on the Z): "))
  96.   (setq lw (getdist "\nWidth of the leg (on the X): "))
  97.   (setq ll (getdist "\nLength of the leg (on the Y): "))
  98.   (setq lh (getdist "\nHeight of the leg (on the Z): "))
  99.   (setq nt (getint "\nNumber of tables to build ?: "))
  100.   (graphscr) 
  101.   (setvar "blipmode" 0)
  102.   (setvar "cmdecho" 0)
  103.   (setq tp (getvar "thickness"))     ;set up for multiple tables
  104.   (repeat nt                         ;set points for base of first leg
  105.     (setq sp (getpoint "\nLower left point for construction: ")) ;create the-
  106.                                      ; chair legs
  107.     (setq l1 sp)
  108.     (repeat 2 
  109.       (setq l2 (polar l1 (dtr 0.0) ll))
  110.       (setq l3 (polar l2 (dtr 90) lw))
  111.       (setq l4 (polar l3 (dtr 180) ll))
  112.       (setvar "thickness" lh)
  113.       (command "line" l1 l2 l3 l4 "c") 
  114.       (setvar "thickness" tp)
  115.       (command "3dface" l1 l2 l3 l4 "") 
  116.       (setq l1 (polar l1 (dtr 0.0) (- tl ll)))
  117.     ) 
  118.     (setq l1 sp)
  119.     (setq l1 (polar l1 (dtr 90) (- tw lw)))
  120.     (repeat 2 
  121.       (setq l2 (polar l1 (dtr 0.0) ll))
  122.       (setq l3 (polar l2 (dtr 90) lw))
  123.       (setq l4 (polar l3 (dtr 180) ll))
  124.       (setvar "thickness" lh)
  125.       (command "line" l1 l2 l3 l4 "c") 
  126.       (setvar "thickness" tp)
  127.       (command "3dface" l1 l2 l3 l4 "") 
  128.       (setq l1 (polar l1 (dtr 0.0) (- tl ll)))
  129.     )                                ;set points for top of first leg
  130.     (setq l1 sp)
  131.     (setq l5 (list (car l1) (cadr l1) (+ (caddr l1) lh)))
  132.     (setq l6 (list (car l2) (cadr l2) (+ (caddr l2) lh)))
  133.     (setq l7 (list (car l3) (cadr l3) (+ (caddr l3) lh)))
  134.     (setq l8 (list (car l4) (cadr l4) (+ (caddr l4) lh))) ;set points for table
  135.     (setq t1 l5)
  136.     (setq t2 (polar t1 (dtr 0.0) tl))
  137.     (setq t3 (polar t2 (dtr 90) tw))
  138.     (setq t4 (polar t3 (dtr 180) tl)) ;set points for top of table
  139.     (setq t5 (list (car t1) (cadr t1) (+ (caddr t1) th)))
  140.     (setq t6 (list (car t2) (cadr t2) (+ (caddr t2) th)))
  141.     (setq t7 (list (car t3) (cadr t3) (+ (caddr t3) th)))
  142.     (setq t8 (list (car t4) (cadr t4) (+ (caddr t4) th))) ;create the table top
  143.     (setvar "thickness" th)
  144.     (command "line" t1 t2 t3 t4 "c") 
  145.     (setvar "thickness" tp)
  146.     (command "3dface" t1 t2 t3 t4 "") 
  147.     (command "3dface" t5 t6 t7 t8 "")
  148.   )
  149. ;;;
  150. ;;;This part of the program will draw 3d cabinets with one shelf
  151. ;;;inserted at the half way point.
  152. (defun c:3dcab ()                    ;get input for variables
  153.   (textscr) 
  154.   (setq w (getdist "\nWidth of cabinet (on the x): "))
  155.   (setq l (getdist "\nLength of the cabinet (on the y): "))
  156.   (setq h (getdist "\nHeight of the cabinet (on the z): "))
  157.   (setq t (getdist "\nThickness of the cabinets (exp 1/4, 1/8): "))
  158.   (setq nc (getint "\nNumber of cabinets to build ?: ")) ;set points for the-
  159.                                      ; base 
  160.   (graphscr) 
  161.   (setvar "blipmode" 0)
  162.   (setvar "cmdecho" 0)
  163.   (setq tp (getvar "thickness"))
  164.   (setq sh (- h t))                  ;set up for multiple cabinets
  165.   (repeat nc 
  166.     (setq sp (getpoint "\nLower left point for construction: "))
  167.     (setq b1 sp)
  168.     (setq b2 (polar b1 (dtr 0.0) w))
  169.     (setq b3 (polar b2 (dtr 90) l))
  170.     (setq b4 (polar b3 (dtr 180) w)) ;set points for the top 
  171.     (setq t1 (list (car b1) (cadr b1) (+ (caddr b1) h)))
  172.     (setq t2 (list (car b2) (cadr b2) (+ (caddr b2) h)))
  173.     (setq t3 (list (car b3) (cadr b3) (+ (caddr b3) h)))
  174.     (setq t4 (list (car b4) (cadr b4) (+ (caddr b4) h))) ;set points for-
  175.                                      ; thickness of cabinets
  176.     ;;left side walls
  177.     (setq l1 (polar b1 (dtr 0.0) t))
  178.     (setq l2 (polar t1 (dtr 0.0) t))
  179.     (setq l3 (polar t4 (dtr 0.0) t))
  180.     (setq l4 (polar b4 (dtr 0.0) t)) ;right side walls
  181.     (setq r1 (polar b2 (dtr 180) t))
  182.     (setq r2 (polar t2 (dtr 180) t))
  183.     (setq r3 (polar t3 (dtr 180) t))
  184.     (setq r4 (polar b3 (dtr 180) t)) ;inside of back
  185.     (setq bk1 (polar l4 (dtr 270) t))
  186.     (setq bk2 (polar r4 (dtr 270) t))
  187.     (setq bk3 (polar r3 (dtr 270) t))
  188.     (setq bk4 (polar l3 (dtr 270) t)) ;inside bottom
  189.     (setq bt1 (list (car l1) (cadr l1) (+ (caddr l1) t)))
  190.     (setq bt2 (list (car r1) (cadr r1) (+ (caddr r1) t)))
  191.     (setq bt3 (list (car bk2) (cadr bk2) (+ (caddr bk2) t)))
  192.     (setq bt4 (list (car bk1) (cadr bk1) (+ (caddr bk1) t))) ;inside top
  193.     (setq tb1 (list (car l2) (cadr l2) (- (caddr l2) t)))
  194.     (setq tb2 (list (car r2) (cadr r2) (- (caddr r2) t)))
  195.     (setq tb3 (list (car bk3) (cadr bk3) (- (caddr bk3) t)))
  196.     (setq tb4 (list (car bk4) (cadr bk4) (- (caddr bk4) t))) ;set points for the-
  197.                                      ; bottom of the shelf
  198.     (setq th (/ t 2))
  199.     (setq sd (- (/ (- (caddr t1) (caddr b1)) 2) th))
  200.     (setq s1 (list (car l1) (cadr l1) sd))
  201.     (setq s2 (list (car r1) (cadr r1) sd))
  202.     (setq s3 (list (car bk2) (cadr bk2) sd))
  203.     (setq s4 (list (car bk1) (cadr bk1) sd)) ;top of the shelf
  204.     (setq s5 (list (car s1) (cadr s1) (+ (caddr s1) t)))
  205.     (setq s6 (list (car s2) (cadr s2) (+ (caddr s2) t)))
  206.     (setq s7 (list (car s3) (cadr s3) (+ (caddr s3) t)))
  207.     (setq s8 (list (car s4) (cadr s4) (+ (caddr s4) t))) ;begin entity creation
  208.     (setvar "thickness" h)
  209.     (command "line" b1 b4 b3 b2 "") 
  210.     (setvar "thickness" sh)
  211.     (command "line" l1 bk1 bk2 r1 "") 
  212.     (setvar "thickness" tp)
  213.     (command "3dface" b1 b2 b3 b4 "") 
  214.     (command "3dface" bt1 bt2 bt3 bt4 "") 
  215.     (command "3dface" tb1 tb2 tb3 tb4 "") 
  216.     (command "3dface" s1 s2 s3 s4 "") 
  217.     (command "3dface" s5 s6 s7 s8 "") 
  218.     (command "3dface" s1 s2 s6 s5 "") 
  219.     (command "3dface" t1 t2 t3 t4 "") 
  220.     (command "3dface" b1 t1 l2 l1 "") 
  221.     (command "3dface" b2 r1 r2 t2 "") 
  222.     (command "3dface" l1 r1 bt2 bt1 "") 
  223.     (command "3dface" tb1 tb2 r2 l2 "") 
  224.     (command "zoom" "e")
  225.   )
  226. ;;;
  227. ;;;This part of the program will build a 3d chair with arms. 
  228. (defun c:armchr ()                   ;get input for variables
  229.   (textscr) 
  230.   (setq sw (getdist "\nWidth of the seat (on the X): "))
  231.   (setq sl (getdist "\nLength of the seat (on the Y): "))
  232.   (setq sh (getdist "\nThickness of the seat (on the Z): "))
  233.   (setq bl (getdist "\nThickness of the back (on the Y): "))
  234.   (setq bh (getdist "\nHeight of the back (on the Z): "))
  235.   (setq lw (getdist "\nWidth of the leg (on the X): "))
  236.   (setq ll (getdist "\nLength of the leg (on the Y): "))
  237.   (setq lh (getdist "\nHeight of the leg (on the Z): "))
  238.   (setq nc (getint "\nNumber of chairs to build ?: "))
  239.   (setq ad (- sl bl))
  240.   (setq aw lw)
  241.   (setq al (/ ll 2))
  242.   (setq at al)
  243.   (setq hat (/ at 2))
  244.   (setq ah (- (/ bh 2) hat))
  245.   (graphscr) 
  246.   (setvar "blipmode" 0)
  247.   (setvar "cmdecho" 0)               ;set points for base of first leg
  248.   (setq tp (getvar "thickness"))     ;set up for multiple chairs
  249.   (repeat nc 
  250.     (setq sp (getpoint "\nLower left point for construction: ")) ;create the-
  251.                                      ; chair legs
  252.     (setq l1 sp)
  253.     (repeat 2 
  254.       (setq l2 (polar l1 (dtr 0.0) ll))
  255.       (setq l3 (polar l2 (dtr 90) lw))
  256.       (setq l4 (polar l3 (dtr 180) ll))
  257.       (setvar "thickness" lh)
  258.       (command "line" l1 l2 l3 l4 "c") 
  259.       (setvar "thickness" tp)
  260.       (command "3dface" l1 l2 l3 l4 "") 
  261.       (setq l1 (polar l1 (dtr 0.0) (- sl ll)))
  262.     ) 
  263.     (setq l1 sp)
  264.     (setq l1 (polar l1 (dtr 90) (- sw lw)))
  265.     (repeat 2 
  266.       (setq l2 (polar l1 (dtr 0.0) ll))
  267.       (setq l3 (polar l2 (dtr 90) lw))
  268.       (setq l4 (polar l3 (dtr 180) ll))
  269.       (setvar "thickness" lh)
  270.       (command "line" l1 l2 l3 l4 "c") 
  271.       (setvar "thickness" tp)
  272.       (command "3dface" l1 l2 l3 l4 "") 
  273.       (setq l1 (polar l1 (dtr 0.0) (- sl ll)))
  274.     )                                ;set points for top of first leg
  275.     (setq l1 sp)
  276.     (setq l5 (list (car l1) (cadr l1) (+ (caddr l1) lh)))
  277.     (setq l6 (list (car l2) (cadr l2) (+ (caddr l2) lh)))
  278.     (setq l7 (list (car l3) (cadr l3) (+ (caddr l3) lh)))
  279.     (setq l8 (list (car l4) (cadr l4) (+ (caddr l4) lh))) ;set points for seat
  280.     (setq s1 l5)
  281.     (setq s2 (polar s1 (dtr 0.0) sl))
  282.     (setq s3 (polar s2 (dtr 90) sw))
  283.     (setq s4 (polar s3 (dtr 180) sl)) ;set points for top of seat
  284.     (setq s5 (list (car s1) (cadr s1) (+ (caddr s1) sh)))
  285.     (setq s6 (list (car s2) (cadr s2) (+ (caddr s2) sh)))
  286.     (setq s7 (list (car s3) (cadr s3) (+ (caddr s3) sh)))
  287.     (setq s8 (list (car s4) (cadr s4) (+ (caddr s4) sh))) ;set points for arm-
  288.                                      ; base
  289.     (setq a1 s5)
  290.     (repeat 2 
  291.       (setq a2 (polar a1 (dtr 0.0) al))
  292.       (setq a3 (polar a2 (dtr 90) aw))
  293.       (setq a4 (polar a3 (dtr 180) al)) ;set points for the armrests
  294.       (setq a5 (list (car a1) (cadr a1) (+ (caddr a1) ah)))
  295.       (setq a6 (polar a5 (dtr 0.0) (- sl bl)))
  296.       (setq a7 (polar a6 (dtr 90) aw))
  297.       (setq a8 (list (car a4) (cadr a4) (+ (caddr a4) ah)))
  298.       (setq a9 (list (car a5) (cadr a5) (+ (caddr a5) at)))
  299.       (setq a10 (list (car a6) (cadr a6) (+ (caddr a6) at)))
  300.       (setq a11 (list (car a7) (cadr a7) (+ (caddr a7) at)))
  301.       (setq a12 (list (car a8) (cadr a8) (+ (caddr a8) at)))
  302.       (setq a13 (polar a5 (dtr 0.0) al))
  303.       (setq a14 (polar a8 (dtr 0.0) al)) ;create the arms
  304.       (setvar "thickness" ah)
  305.       (command "line" a1 a2 a3 a4 "c") 
  306.       (setvar "thickness" at)
  307.       (command "line" a6 a5 a8 a7 "") 
  308.       (setvar "thickness" tp)
  309.       (command "3dface" a9 a10 a11 a12 "") 
  310.       (command "3dface" a13 a6 a7 a14 "") 
  311.       (setq a1 (polar s5 (dtr 90) (- sw aw)))
  312.     )                                ;set points for back
  313.     (setq b2 s6)
  314.     (setq b1 (polar b2 (dtr 180) bl))
  315.     (setq b4 (polar b1 (dtr 90) sw))
  316.     (setq b3 s7)                     ;set points for the top of the back
  317.     (setq b5 (list (car b1) (cadr b1) (+ (caddr b1) bh)))
  318.     (setq b6 (list (car b2) (cadr b2) (+ (caddr b2) bh)))
  319.     (setq b7 (list (car b3) (cadr b3) (+ (caddr b3) bh)))
  320.     (setq b8 (list (car b4) (cadr b4) (+ (caddr b4) bh))) ;create the chair bas-
  321.                                      ;e
  322.     (setvar "thickness" sh)
  323.     (command "line" s1 s2 s3 s4 "c") 
  324.     (setvar "thickness" tp)
  325.     (command "3dface" s1 s2 s3 s4 "") 
  326.     (command "3dface" s5 b1 b4 s8 "") ;create the chair back
  327.     (setvar "thickness" bh)
  328.     (command "line" b1 b2 b3 b4 "c") 
  329.     (setvar "thickness" tp)
  330.     (command "3dface" b5 b6 b7 b8 "")
  331.   )
  332. ;;;
  333. ;;;end of program - start of dtr/rtd conversions
  334. (defun dtr (a) 
  335.   (* pi (/ a 180.0))
  336. (defun rtd (a) 
  337.   (/ (* a 180.0) pi)
  338. ;;;  
  339. (princ "\nThis program contains the commands: ") 
  340. (princ "\nTable, 3dcab, Chair, and Armchr.") 
  341. (princ) 
  342. ;;;
  343.  
  344.